//
//  MKOPView.m
//  ManKeCartoon
//
//  Created by dllo on 15/10/21.
//  Copyright © 2015年 ManKe. All rights reserved.
//

#import "MKOPView.h"
#import "MKBaseHeader.h"
@implementation MKOPView

#pragma mark - 设置圆形button
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        NSArray *arr = @[@"分类",@"搜索",@"追更",@"资讯"];
        
        for (int i = 0; i < 4; i++) {
            self.OPbutton = [UIButton buttonWithType:UIButtonTypeCustom];
            _OPimage = [[UIImageView alloc] init];
            _OPlabel = [[UILabel alloc] init];
            
            [_OPbutton setFrame:CGRectMake(20+i*(self.frame.size.height/2+(SCREEN_WIDTH-40-2*self.frame.size.height)/3.), 15, self.frame.size.height / 2, self.frame.size.height / 2)];
            
            // 设置圆形button
            [_OPbutton.layer setMasksToBounds:YES];
            [_OPbutton.layer setCornerRadius:self.frame.size.height / 4];
            [_OPbutton.layer setBorderWidth:1];
            [_OPbutton.layer setBorderColor:[UIColor orangeColor].CGColor];
            [_OPbutton setBackgroundColor:[UIColor colorWithRed:0.96 green:0.95 blue:0.93 alpha:1]];
            _OPbutton.tag = 300 + i;
            [self addSubview:_OPbutton];
            
            [_OPlabel setFrame:CGRectMake(_OPbutton.frame.origin.x, 25 + _OPbutton.frame.size.height, _OPbutton.frame.size.width, 20)];
            [_OPlabel setText:arr[i]];
            [_OPlabel setTextAlignment:NSTextAlignmentCenter];
            [_OPlabel setFont:[UIFont systemFontOfSize:18]];
            [self addSubview:_OPlabel];
            
            [_OPimage setFrame:CGRectMake(_OPbutton.frame.size.width / 4, _OPbutton.frame.size.width / 4, _OPbutton.frame.size.width / 2, _OPbutton.frame.size.height / 2)];
            [_OPimage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"LB%d",i+1]]];
            [_OPbutton addSubview:_OPimage];
//            [_OPbutton addTarget:self action:@selector(categoryClick:) forControlEvents:UIControlEventTouchUpInside];

//            [_OPbutton addTarget:self action:@selector(categoryClick:) forControlEvents:UIControlEventTouchUpInside];
            
        }
        
        
        
    }
    return self;
}


@end
